fix(builtins): implement declare -f for function display and lookup#822
Merged
fix(builtins): implement declare -f for function display and lookup#822
declare -f for function display and lookup#822Conversation
Closes #792 — `declare -f` now properly handles the -f flag: - `declare -f name` returns exit 1 when function doesn't exist (was returning 0) - `declare -f name` prints function definition and returns 0 when it exists - `declare -f` with no args lists all defined functions This fixes subprocess isolation for script-by-path execution: `declare -f` was the last piece needed — the isolation itself (clearing functions in child) already worked, but `declare -f helper` always returned success.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
declare -fflag handling in the declare builtindeclare -f namenow returns exit 1 when function doesn't exist (was always returning 0)declare -f nameprints function stub and returns 0 when function existsdeclare -fwith no args lists all defined functionsdeclare -f helperalways returned success regardlessTest plan
declare_f_nonexistent_function_returns_1— verifies exit code 1 for missing functionsdeclare_f_existing_function_prints_definition— verifies exit code 0 and output for existing functionsdeclare_f_no_args_lists_all_functions— verifies listing all functionsexec_script_functions_not_inherited— verifies functions not visible in subprocess scriptscargo test --all-features)cargo fmt --checkandcargo clippycleanCloses #792